<div id="tab6" class="tab">
    <div class="tab-labels">
        <div class="xian"></div>
        三者车损失
    </div>
    <div style="border:1px solid #FF5722; padding-top: 10px;">
        <form action="">
            <table class="layui-table" id="tabProduct3">
                <tr style="background:#4e73df;color: #fff;" class="ys">
                    <td style="width: 66px;">选择</td>
                    <td>序号</td>
                    <td>车牌号</td>
                    <td>驾驶员</td>
                    <td>性别</td>
                    <td>电话</td>
                    <td>车辆品牌</td>
                    <td>厂牌型号</td>
                    <td>车辆款式</td>
                    <td>车架号</td>
                    <td>发动机号</td>
                    <td>维修厂名称</td>
                    <td>车损</td>
                    <td>财物</td>
                    <td>汇总</td>
                    <td>状态</td>
                </tr>
                {empty name="sanche"}
                <tr>
                    <td><input type="checkbox" style="width: 15px;height: 15px;display: block;"
                               name="id" disabled></td>
                    <td><input type="text" name="xuhao" value="1" readonly></td>
                    <td><input type="text" name="car_num" readonly></td>
                    <td><input type="text" name="car_user" readonly></td>
                    <td><input type="text" name="sex" readonly></td>
                    <td><input type="text" name="phone" readonly></td>
                    <td><input type="text" name="brand" readonly></td>
                    <td><input type="text" name="model" readonly></td>
                    <td><input type="text" name="style" readonly></td>
                    <td><input type="text" name="car_vin" readonly></td>
                    <td><input type="text" name="car_engine" readonly></td>
                    <td><input type="text" name="weixiuchang" readonly></td>
                    <td><input type="text" name="heji" readonly></td>
                    <td><input type="text" name="c_zongji" readonly></td>
                    <td><input type="text" name="sanche_huizong" readonly></td>
                    <td><input type="text" name="status" readonly></td>
                </tr>
                {/empty}
                {volist name="sanche" id="sanchess"}
                <tr>
                    <td><input type="checkbox" style="width: 15px;height: 15px;display: block;"
                               name="id" value="{$sanchess.id}" disabled></td>
                    <td><input type="text" name="xuhao" value="{$sanchess.xuhao}" readonly></td>
                    <td><input type="text" name="car_num" value="{$sanchess.car_num}"
                               title="{$sanchess.car_num}" readonly onclick="openDialog({$sanchess.id})"
                               style="text-decoration: underline;color:blue;cursor: pointer;"></td>
                    <td><input type="text" value="{$sanchess.car_user}" name="car_user" readonly></td>
                    <td><input type="text" value="{$sanchess.sex}" name="sex" readonly></td>
                    <td><input type="text" value="{$sanchess.phone}" name="phone" readonly></td>
                    <td><input type="text" value="{$sanchess.brand}" name="brand" readonly></td>
                    <td><input type="text" name="model" value="{$sanchess.model}" readonly></td>
                    <td><input type="text" name="style" value="{$sanchess.style}" readonly></td>
                    <td><input type="text" name="car_vin" value="{$sanchess.car_vin}" readonly></td>
                    <td><input type="text" name="car_engine" value="{$sanchess.car_engine}" readonly>
                    </td>
                    <td><input type="text" name="weixiuchang" value="{$sanchess.weixiuchang}" readonly>
                    </td>
                    <td><input type="text" name="heji" value="{$sanchess.heji}" readonly></td>
                    <td><input type="text" name="c_zongji" value="{$sanchess.c_zongji}" readonly></td>
                    <td><input type="text" name="sanche_huizong" value="{$sanchess.sanche_huizong}"
                               readonly></td>
                    <td><input type="text" name="status" value="{$sanchess.status}" readonly></td>
                </tr>
                {/volist}
            </table>
            <div class="conts" style="display: none">
                <div class="input">
                    <span>车损合计</span>
                    <input type="text" readonly value="{$row.sc_heji}" name="sc_heji">
                </div>
                <div class="input">
                    <span>财物合计</span>
                    <input type="text" readonly name="sc_zongji" value="{$row.sc_zongji}">
                </div>
                <div class="input">
                    <span>其他汇总</span>
                    <input type="text" readonly name="sc_huizong" value="{$row.sc_huizong}">
                </div>
                <div class="input">
                    <span>总合计</span>
                    <input type="text" readonly name="z_heji" value="{$row.z_heji}">
                </div>
            </div>
        </form>

        <hr>
        <?php if( request()->controller()== "Bushen.hejia"){?>
        <div class="conts">
            <span style="width:98%;margin: 1%;">审核意见</span>
            <textarea name="" id="chesun_3_text" cols="30" rows="10"
                      style="width:98%;height: 100px;margin: 1%;"></textarea>
        </div>
        <div style="padding: 10px;display: flex;justify-content: center;">

            <button type="button" class="layui-btn layui-btn-danger" id="chesun_3">
                三者车车损失定损通过审核
            </button>
            <!--<button type="button" class="layui-btn layui-btn-danger"  id="chesun_31">无损失</button>-->
            <!--<button type="button" class="layui-btn layui-btn-danger"  id="chesun_32">未参统</button>-->
            <!--<button type="button" class="layui-btn layui-btn-danger"  id="chesun_33">无需补偿</button>-->

            <button type="button" class="layui-btn layui-btn-warm" id="chesun_bk3">退回</button>

        </div>
        <?php }?>
        <script>
            $('#chesun_3').click(function () {
                var chesun_3_text = $('#chesun_3_text').val();
                if (chesun_3_text == '') {
                    layer.msg("请输入审核原因");
                    return false
                }
                layer.confirm('确定' + $(this).text() + '？', {
                    icon: 3,
                    title: $(this).text()
                }, function (index) {
                    $.ajax({
                        url: "{:url('bushen/hejia/shenhe_post')}",
                        data: {
                            id: "{$orderid}",
                            bid: "{$bid}",
                            chesun_3: 3,
                            tuihui: chesun_3_text,
                        },
                        type: 'post',
                        dataType: 'json',
                        success: function (res) {
                            if (res.code == 1) {
                                layer.msg(res.msg, {time: 2000}, function () {
                                    layer.closeAll()
                                    parent.layer.closeAll();
                                    parent.$("#table").bootstrapTable('refresh', {});
                                });
                            } else {
                                layer.msg(res.msg);
                            }
                        }
                    })
                });
            })

            $('#chesun_31').click(function () {
                var chesun_3_text = $('#chesun_3_text').val();
                if (chesun_3_text == '') {
                    layer.msg("请输入审核原因");
                    return false
                }
                layer.confirm('确定' + $(this).text() + '？', {
                    icon: 3,
                    title: $(this).text()
                }, function (index) {
                    $.ajax({
                        url: "{:url('bushen/hejia/shenhe_post')}",
                        data: {
                            id: "{$orderid}",
                            bid: "{$bid}",
                            chesun_3: 3,
                            tuihui: chesun_3_text,
                        },
                        type: 'post',
                        dataType: 'json',
                        success: function (res) {
                            if (res.code == 1) {
                                layer.msg(res.msg, {time: 2000}, function () {
                                    layer.closeAll()
                                    parent.layer.closeAll();
                                    parent.$("#table").bootstrapTable('refresh', {});
                                });
                            } else {
                                layer.msg(res.msg);
                            }
                        }
                    })
                });
            })

            $('.chesun_32').click(function () {
                layer.confirm('确定' + $(this).text() + '？', {
                    icon: 3,
                    title: $(this).text()
                }, function (index) {
                    $.ajax({
                        url: "{:url('bshenhe/shenhe_post')}",
                        data: {
                            id: "{$orderid}",
                            bid: "{$bid}",
                            chesun_3: 3,
                            tuihui: $.trim($('.chesun_3_text').val()),
                        },
                        type: 'post',
                        dataType: 'json',
                        success: function (res) {
                            layer.close(index);
                            layer.msg(res.msg);
                            if (res.code == 1) {
                                window.location.href = 'fenxiang';
                            }
                            //$('.chesun_3').hide();
                            // $('.chesun_bk3').hide();
                        }
                    })
                });
            })

            $('.chesun_33').click(function () {
                layer.confirm('确定' + $(this).text() + '？', {
                    icon: 3,
                    title: $(this).text()
                }, function (index) {
                    $.ajax({
                        url: "{:url('bshenhe/shenhe_post')}",
                        data: {
                            id: "{$orderid}",
                            bid: "{$bid}",
                            chesun_3: 3,
                            tuihui: $.trim($('.chesun_3_text').val()),
                        },
                        type: 'post',
                        dataType: 'json',
                        success: function (res) {
                            layer.close(index);
                            layer.msg(res.msg);
                            if (res.code == 1) {
                                window.location.href = 'fenxiang';
                            }
                            //$('.chesun_3').hide();
                            // $('.chesun_bk3').hide();
                        }
                    })
                });
            })

            $('#chesun_bk3').click(function () {
                var chesun_3_text = $('#chesun_3_text').val();
                if (chesun_3_text == '') {
                    layer.msg("请输入审核原因");
                    return false
                }
                layer.confirm('确定' + $(this).text() + '？', {
                    icon: 3,
                    title: $(this).text()
                }, function (index) {
                    $.ajax({
                        url: "{:url('bushen/hejia/shenhe_post')}",
                        data: {
                            id: "{$orderid}",
                            bid: "{$bid}",
                            chesun_3: 2,
                            tuihui: chesun_3_text,
                        },
                        type: 'post',
                        dataType: 'json',
                        success: function (res) {
                            if (res.code == 1) {
                                layer.msg(res.msg, {time: 2000}, function () {
                                    layer.closeAll()
                                    parent.layer.closeAll();
                                    parent.$("#table").bootstrapTable('refresh', {});
                                });
                            } else {
                                layer.msg(res.msg);
                            }
                        }
                    })
                });
            })
        </script>
    </div>
    <script>
        function test3() {
            var div4 = document.getElementById("div4");
            if (div4.style.display == "block") {
                div4.style.display = "none";
            } else {
                div4.style.display = "block";
            }
        }
    </script>


    <!--<p>汇总</p>-->
    <div id="light" class="white_content">
        <div class="content">
            <!--三者车-->
            <div>
                <form action="">
                    <div class="titles">
                        <p><font></font>三者车定损</p>
                    </div>
                    <input id="sanche_bid" type="hidden" name="bid" value="{$row.id}">
                    <table class="layui-table" id="table">
                        <tr style="background:#4e73df;color: #fff;" class="ys">
                            <td></td>
                            <td>车牌号</td>
                            <!--<td>车辆品牌</td>-->
                            <td>车型型号</td>
                            <!--<td>车辆年款</td>-->
                            <td>车架号</td>
                            <td>发动机号</td>
                            <!--<td>维修厂名称</td>-->
                            <td>驾驶员</td>
                            <!--<td>性别</td>-->
                            <td>联系电话</td>
                        </tr>
                        <tr>
                            <td><input type="hidden" id="sanche_id" value=""></td>
                            <td><input type="text" value="" name="car_num" readonly>
                            </td>
                            <td><input type="text" name="model" value="" readonly></td>
                            <td><input type="text" name="car_vin" value="" readonly>
                            </td>
                            <td><input type="text" name="car_engine" value=""
                                       readonly></td>
                            <td><input type="text" value="" name="car_user" readonly>
                            </td>
                            <td><input type="text" value="" name="phone" readonly></td>
                        </tr>
                    </table>
                    <div class="titles">
                        <p><font></font>配件定损</p>
                    </div>
                    {if $sanche[0]['status'] eq 1}
                    <input type="button" onclick="hd_sanche(this)" value="保存数据"
                           style="padding: 5px 10px;height:30px;border: none;background:#1b4fe7;color: #fff;">
                    {/if}
                    <input type="button" onclick="export_excel(3)" value="导出配件数据"
                           style="padding: 5px 10px;height:30px;border: none;background:#1b4fe7;color: #fff;">
                    <table class="layui-table" id="tabProduct7">
                        <tr style="background:#4e73df;color: #fff;" class="ys">
                            <td style="width: 66px;">选择</td>
                            <td>序号</td>
                            <!--<td>服务种类</td>-->
                            <td>配件名称</td>
                            <td>价格方案</td>
                            <td>价格</td>
                            <td>数量</td>
                            <td>金额</td>
                            <!-- <td>折扣</td> -->
                            <td>核定价格</td>
                            <td>核定数量</td>
                            <td>核定金额</td>
                            <td>备注</td>
                        </tr>
                        <tr>
                            <td><input type="checkbox" readonly
                                       style="width: 15px;height: 15px;display: block;" name="id"
                                       disabled value=""></td>
                            <td><input type="text" name="xuhao" readonly value="1"></td>
                            <!--<td><input type="text" name="type" value="" readonly></td>-->
                            <td><input type="text" name="name" value="" readonly></td>
                            <td><input type="text" name="fangan" value="" readonly></td>
                            <td><input type="text" name="price" value="" readonly></td>
                            <td><input type="text" name="num" value="" readonly></td>
                            <td><input type="text" name="money" value="" readonly></td>
                            <!-- <td><input type="text" name="zhekou" value="100" readonly></td> -->
                            <td><input type="text" name="price_he" value="" readonly></td>
                            <td><input type="text" name="num_he" value="" readonly></td>
                            <td><input type="text" name="hejia" value="" readonly></td>
                            <td><input type="text" name="beizhu" value="" readonly></td>
                        </tr>

                    </table>
                    <table class="layui-table" id="he7">
                        <tr>
                            <td>小计</td>
                            <td><input type="text" readonly></td>
                            <td><input type="text" readonly></td>
                            <!-- <td><input type="text" readonly></td> -->
                            <td><input type="text" readonly></td>
                            <td><input type="text" readonly></td>
                            <td><input type="text" readonly></td>
                            <td><input type="text" id="x_money" name="x_money" class="x_money" value="" readonly></td>
                            <td><input type="text" readonly></td>
                            <td><input type="text" readonly></td>
                            <td><input type="text" id="hd_c_money" name="x_hejia" class="hd_c_money" value="" readonly>
                            </td>
                            <td><input type="text" readonly></td>
                        </tr>
                    </table>
                    <!--               </form>-->
                    <!--<p>汇总</p>-->
                    <div class="conts">
                        <div class="input">
                            <span>合计</span>
                            <input type="text" placeholder="合计" id="p_heji" class="p_heji" value="" name="p_heji"
                                   readonly>
                        </div>
                        <div class="input">
                            <span>残值</span>
                            <input type="text" placeholder="残值" id="canzhi" class="canzhi" value="" name="canzhi"
                                   readonly>
                        </div>
                        <div class="input">
                            <span>总计</span>
                            <input type="text" placeholder="总计" id="p_zongji" class="p_zongji" value="" name="p_zongji"
                                   readonly>
                        </div>
                    </div>
                    <div class="conts">
                        <div class="input">
                            <span>核定合计</span>
                            <input oninput="hd_c()" type="text" placeholder="核定合计" id="hd_c_heji"
                                   value="" name="p_heji" class="hd_c_heji">
                        </div>
                        <div class="input">
                            <span>核定残值</span>
                            <input oninput="hd_c()" type="text" placeholder="核定残值" id="hd_c_canzhi"
                                   value="" name="canzhi" class="hd_c_canzhi">
                        </div>
                        <div class="input">
                            <span>核定总计</span>
                            <input oninput="hd_c()" type="text" placeholder="核定总计" id="hd_c_zongji"
                                   value="" name="p_zongji" class="hd_c_zongji">
                        </div>
                    </div>
                    <div class="titles">
                        <p><font></font>工时核定</p>
                    </div>
                    {if $sanche[0]['status'] eq 1}
                    <input type="button" onclick="hd_sangong(this)" value="保存数据"
                           style="padding: 5px 10px;height:30px;border: none;background:#1b4fe7;color: #fff;">
                    {/if}
                    <input type="button" onclick="export_excel(4)" value="导出工时数据"
                           style="padding: 5px 10px;height:30px;border: none;background:#1b4fe7;color: #fff;">
                    <table class="layui-table" id="tabProduct8">
                        <tr style="background:#4e73df;color: #fff;" class="ys">
                            <td style="width: 66px;">选择</td>
                            <td>序号</td>
                            <!--<td>服务种类</td>-->
                            <td>配件名称</td>
                            <td>价格方案</td>
                            <td>价格</td>
                            <td>数量</td>
                            <td>金额</td>
                            <!-- <td>折扣</td> -->
                            <td>核定价格</td>
                            <td>核定数量</td>
                            <td>核定金额</td>
                            <td>备注</td>
                        </tr>
                        <tr>
                            <td><input type="checkbox" style="width: 15px;height: 15px;display: block;"
                                       name="id" value=""></td>
                            <td><input type="text" name="xuhao" readonly value="1"></td>
                            <!--<td><input type="text" name="type" value="" readonly></td>-->
                            <td><input type="text" name="name" value="" readonly></td>
                            <td><input type="text" name="fangan" value="" readonly></td>
                            <td><input type="text" name="price" value="" readonly></td>
                            <td><input type="text" name="num" value="" readonly></td>
                            <td><input type="text" name="money" value="" readonly></td>
                            <!-- <td><input type="text" name="zhekou" value="100" readonly></td> -->
                            <td><input type="text" name="price_he" value="" readonly></td>
                            <td><input type="text" name="num_he" value="" readonly></td>
                            <td><input type="text" name="hejia" value="" readonly></td>
                            <td><input type="text" name="beizhu" value="" readonly></td>
                        </tr>
                    </table>
                    <table class="layui-table" id="he8">
                        <tr>
                            <td>小计</td>
                            <td><input type="text" readonly></td>
                            <td><input type="text" readonly></td>
                            <td><input type="text" readonly></td>
                            <!-- <td><input type="text" readonly></td> -->
                            <td><input type="text" readonly></td>
                            <td><input type="text" readonly></td>
                            <td><input type="text" id="g_money" class="g_money" value="" name="g_money" readonly></td>
                            <td><input type="text" readonly></td>
                            <td><input type="text" readonly></td>
                            <td><input type="text" id="hd_d_money" class="hd_d_money" value="" name="g_hejia" readonly>
                            </td>
                            <td><input type="text" readonly></td>
                        </tr>
                    </table>
                    <!--                 </form>-->
                    <!--<p>合计</p>-->
                    <div class="conts">
                        <div class="input">
                            <span>施救费</span>
                            <input type="text" id="g_shijiu" class="g_shijiu" readonly value="" name="g_shijiu">
                        </div>
                        <div class="input">
                            <span>总计</span>
                            <input type="text" id="g_zongji" class="g_zongji" readonly value="" name="g_zongji">
                        </div>
                    </div>
                    <div class="conts">
                        <div class="input">
                            <span>核定施救费</span>
                            <input oninput="hd_d()" type="text" id="hd_d_shijiu" class="hd_d_shijiu" value=""
                                   name="hd_g_shijiu">
                        </div>
                        <div class="input">
                            <span>核定总计</span>
                            <input type="text" id="hd_d_zongji" class="hd_d_zongji"  name="hd_g_zongji" value="">
                        </div>
                    </div>
                    <div class="conts" style="display: none">
                        <div class="input">
                            <span>费用合计</span>
                            <input type="text" readonly name="heji" id="heji" class="heji">
                        </div>
                    </div>

                    <div class="conts">
                        <span style="width:98%;margin: 1%;">备注说明</span>
                        <textarea name="beizhu" id="beizhu" readonly cols="30" rows="10"
                                  style="width:98%;height: 100px;margin: 1%;"></textarea>
                    </div>
                    <div class="bao" style="width:30%;height: 30px;margin:20px auto;">
<!--                        <button type="button" onclick="closeDialog()"-->
<!--                                style="width:50%;height:100%;border: none;background:#1b4fe7;color: #fff;-webkit-border-radius:5px ;-moz-border-radius:5px ;border-radius: 5px;">-->
<!--                            关闭-->
<!--                        </button>-->
                    </div>
                    <!--</div>-->
                </form>
            </div>
        </div>
    </div>
    <div id="fade" class="black_overlay"></div>
    <script>
        function export_excel(type) {
            // 三者车使用的函数
            var bid = "{$bid}";
            window.location.href = "export_excel?id=" + bid + "&type=" + type;
        }

        function hd_sanche(sub) {
            layer.confirm('请确认是否已填完数据', {
                icon: 3
            }, function (index) {
                var ids = $('.hd_c_id');
                var price = $('.hd_c_price');
                var num = $('.hd_c_num');
                var money = $('.hd_c_hejia');
                var bid = document.getElementById('sanche_bid').value;
                var sanche_id = document.getElementById('sanche_id').value;

                var c_id = new Array();
                var c_price = new Array();
                var c_num = new Array();
                var c_money = new Array();

                for (var i = 0; i < ids.length; i++) {
                    c_id[i] = ids[i].value;
                }
                for (var i = 0; i < price.length; i++) {
                    c_price[i] = price[i].value;
                }
                for (var i = 0; i < num.length; i++) {
                    c_num[i] = num[i].value;
                }
                for (var i = 0; i < money.length; i++) {
                    c_money[i] = money[i].value;
                }

                var hd_c_heji = $(".hd_c_heji").val();
                var hd_c_zongji = $(".hd_c_zongji").val();
                var hd_c_canzhi = $(".hd_c_canzhi").val();

                $.ajax({
                    url: "{:url('bushen/hejia/hd_sanpeis')}",
                    data: {
                        id: c_id,
                        price: c_price,
                        num: c_num,
                        money: c_money,
                        bid: bid,
                        sanche_id: sanche_id,
                        hd_c_heji: hd_c_heji,
                        hd_c_zongji: hd_c_zongji,
                        hd_c_canzhi: hd_c_canzhi,
                    },
                    type: 'post',
                    dataType: 'json',
                    success: function (res) {
                        layer.msg(res.msg);
                        return false;
                    }
                })
            });
        }

        function hd_c() {
            var price = $('.hd_c_price');
            var num = $('.hd_c_num');
            var money = $('.hd_c_hejia');
            var sum = 0;
            for (var i = 0; i < price.length; i++) {
                money[i].value = price[i].value * num[i].value;
                sum += price[i].value * num[i].value;
            }
            $(".hd_c_money").val(sum.toFixed(2));
            $(".hd_c_heji").val(sum.toFixed(2));
            var hd_c_canzhi = $(".hd_c_canzhi").val();
            console.log(hd_c_canzhi)
            var hd_c_zongji = sum - Number(hd_c_canzhi);
            if (!isNaN(hd_c_zongji)) {
                $(".hd_c_zongji").val(hd_c_zongji.toFixed(2));
            }
        }

        hd_c();

        function d_c() {
            var price = $('.d_c_price');
            var num = $('.d_c_num');
            var money = $('.d_c_hejia');
            var sum = 0;
            for (var i = 0; i < price.length; i++) {
                money[i].value = price[i].value * num[i].value;
                sum += price[i].value * num[i].value;
            }
            $(".d_c_money").val(sum.toFixed(2));
            $(".p_heji").val(sum.toFixed(2));
            console.log(sum.toFixed(2))
            var hd_c_canzhi = $(".d_c_canzhi").val();
            var hd_c_zongji = sum - Number(hd_c_canzhi);
            if (!isNaN(hd_c_zongji)) {
                $(".d_c_zongji").val(hd_c_zongji);
            }
        }
    </script>
    <script>
        function hd_sangong(sub) {
            layer.confirm('请确认是否已填完数据', {
                icon: 3
            }, function (index) {
                var ids = $('.hd_d_id');
                var price = $('.hd_d_price');
                var num = $('.hd_d_num');
                var money = $('.hd_d_hejia');
                var bid = document.getElementById('sanche_bid').value;
                var sanche_id = document.getElementById('sanche_id').value;

                var d_id = new Array();
                var d_price = new Array();
                var d_num = new Array();
                var d_money = new Array();

                for (var i = 0; i < ids.length; i++) {
                    d_id[i] = ids[i].value;
                }
                for (var i = 0; i < price.length; i++) {
                    d_price[i] = price[i].value;
                }
                for (var i = 0; i < num.length; i++) {
                    d_num[i] = num[i].value;
                }
                for (var i = 0; i < money.length; i++) {
                    d_money[i] = money[i].value;
                }

                var hd_d_shijiu = $(".hd_d_shijiu").val();
                var hd_d_zongji = $(".hd_d_zongji").val();

                $.ajax({
                    url: "{:url('bushen/hejia/hd_sangongs')}",
                    data: {
                        id: d_id,
                        price: d_price,
                        num: d_num,
                        money: d_money,
                        bid: bid,
                        sanche_id: sanche_id,
                        hd_d_shijiu: hd_d_shijiu,
                        hd_d_zongji: hd_d_zongji,
                    },
                    type: 'post',
                    dataType: 'json',
                    success: function (res) {
                        layer.msg(res.msg);
                        return false;
                    }
                })
            });
        }

        function hd_d() {
            var price = $('.hd_d_price');
            var num = $('.hd_d_num');
            var money = $('.hd_d_hejia');
            var sum = 0;
            for (var i = 0; i < price.length; i++) {
                money[i].value = price[i].value * num[i].value;
                sum += price[i].value * num[i].value;
            }
            $(".hd_d_money").val(sum.toFixed(2));
            $(".hd_d_heji").val(sum.toFixed(2));
            var hd_d_shijiu = $(".hd_d_shijiu").val();
            var hd_d_zongji = sum + Number(hd_d_shijiu);
            if (!isNaN(hd_d_zongji)) {
                console.log(hd_d_zongji,2222)
                // console.log($(".hd_d_zongji"))
                $(".hd_d_zongji").val(hd_d_zongji)
                // $(".hd_d_zongji").attr('value',hd_d_zongji);
            }
        }
    </script>
    <script type="text/javascript">
        function openDialog(id) {
            // 1. 先打开弹窗（显示加载中状态）
            var $light2Content = $('#light').contents(); // 先保存引用
            var layerIndex = layer.open({
                type: 1,
                title: '加载中...',
                content: `
                    <div style="
                      position: absolute;
                      top: 50%;
                      left: 50%;
                      transform: translate(-50%, -50%);
                      text-align: center;
                    ">
                      <i class="fa fa-spinner fa-pulse fa-3x fa-fw"></i>
                      <p style="margin-top: 10px">加载中...</p>
                    </div>
                  `,
                end: function() {
                    // 弹窗关闭时，把内容放回 #light2
                    $('#light').append($light2Content);
                },
                area: ['80%', '80%'],
                shadeClose: false // 禁止点击遮罩关闭
            });
            $.ajax({
                url: "{:url('bushen/hejia/liulan')}",
                data: {id: id},
                type: 'post',
                dataType: 'json',
                success: function (res) {
                    var html = '';
                    if (res.status == true) {
                        html = "<tr>" +
                            "<td><input type='hidden' id='sanche_id' name='' value=" + res.data.sanche.id + "></td>" +
                            "<td><input type='text' readonly name='car_num' value=" + res.data.sanche.car_num + "></td>" +
                            "<td><input type='text' readonly name='model' value=" + res.data.sanche.model + "></td>" +
                            "<td><input type='text' readonly name='car_vin' value=" + res.data.sanche.car_vin + "></td>" +
                            "<td><input type='text' readonly name='car_engine' value=" + res.data.sanche.car_engine + "></td>" +
                            "<td><input type='text' readonly name='car_user' value=" + res.data.sanche.car_user + "></td>" +
                            "<td><input type='text' readonly  name='phone' value=" + res.data.sanche.phone + "></td>" +
                            "</tr>";
                        $("#table tr").slice(1).remove();
                        $('#table').append(html);
                        var html1 = '';
                        var html2 = '';
                        var html3 = '';
                        if (res.data.sanpei.length > 0) {
                            for (var i = 0; i < res.data.sanpei.length; i++) {
                                var price_he = '';
                                if (res.data.sanpei1 == 1) {
                                    if (res.data.sanpei[i].price_he > 0) {
                                        price_he = res.data.sanpei[i].price_he;
                                    } else {
                                        price_he = res.data.sanpei[i].price;
                                    }
                                } else {
                                    price_he = res.data.sanpei[i].price_he;
                                }
                                var num_he = '';
                                if (res.data.sanpei1 == 1) {
                                    if (res.data.sanpei[i].num_he > 0) {
                                        num_he = res.data.sanpei[i].num_he;
                                    } else {
                                        num_he = res.data.sanpei[i].num;
                                    }
                                } else {
                                    num_he = res.data.sanpei[i].num_he;
                                }
                                var hejia = '';
                                if (res.data.sanpei1 == 1) {
                                    if (res.data.sanpei[i].hejia > 0) {
                                        hejia = res.data.sanpei[i].hejia;
                                    } else {
                                        hejia = res.data.sanpei[i].money;
                                    }
                                } else {
                                    hejia = res.data.sanpei[i].hejia;
                                }
                                html1 += "<tr>" +
                                    "<td><input class='hd_c_id' type='checkbox' style='width: 15px;height: 15px;display: block;' disabled name='id' value=" + res.data.sanpei[i].id + "></td>" +
                                    "<td><input type='text' name='xuhao' readonly value=" + res.data.sanpei[i].xuhao + "></td>" +
                                    // "<td><input type='text' name='type' readonly value=" + res.data.sanpei[i].type + "></td>" +
                                    "<td><input type='text' name='name' readonly  value=" + res.data.sanpei[i].name + "></td>" +
                                    "<td><input type='text' name='fangan' readonly value=" + res.data.sanpei[i].fangan + "></td>" +
                                    "<td><input class='d_c_price' type='text' name='price' readonly value=" + res.data.sanpei[i].price + " ></td>" +
                                    "<td><input class='d_c_num' type='text' name='num' readonly value=" + res.data.sanpei[i].num + "></td>" +
                                    "<td><input class='d_c_hejia' type='text' name='money' readonly  value=" + res.data.sanpei[i].money + "></td>" +
                                    /*"<td><input type='text' name='zhekou' readonly value=" + res.data.sanpei[i].zhekou + "></td>" +*/
                                    "<td><input oninput='hd_c()' class='hd_c_price' type='text' name='price_he'  value=" + price_he + "></td>" +
                                    "<td><input oninput='hd_c()' class='hd_c_num' type='text' name='num_he'  value=" + num_he + "></td>" +
                                    "<td><input class='hd_c_hejia' type='text' name='hejia'  value=" + hejia + "></td>" +
                                    "<td><input type='text' name='beizhu' readonly value=" + res.data.sanpei[i].beizhu + "></td>" +
                                    "</tr>";
                            }
                        } else {
                            html1 += "<tr>" +
                                "<td><input type='checkbox' style='width: 15px;height: 15px;display: block;' disabled name='id'></td>" +
                                "<td><input type='text' name='xuhao' value='1' readonly ></td>" +
                                // "<td><input type='text' name='type' readonly></td>" +
                                "<td><input type='text' name='name' readonly></td>" +
                                "<td><input type='text' name='fangan' readonly></td>" +
                                "<td><input type='text' name='price' readonly ></td>" +
                                "<td><input type='text' name='num' readonly ></td>" +
                                "<td><input type='text' name='money' readonly ></td>" +
                                /*"<td><input type='text' name='zhekou' readonly ></td>" +*/
                                "<td><input type='text' name='price_he' readonly ></td>" +
                                "<td><input type='text' name='num_he' readonly ></td>" +
                                "<td><input type='text' name='hejia' readonly ></td>" +
                                "<td><input type='text' name='beizhu' readonly ></td>" +
                                "</tr>";
                        }

                        $("#tabProduct7 tr").slice(1).remove();
                        $('#tabProduct7').append(html1);
                        setTimeout(function(){
                            $('.x_money').val(res.data.sanche.x_money);
                            // $('.x_hejia').val(res.data.sanche.x_hejia);
                            $('.hd_c_money').val(res.data.sanche.x_hejia);
                            // $('.p_heji').val(res.data.sanche.p_heji);
                            $('.canzhi').val(res.data.sanche.canzhi);
                            $('.p_zongji').val(res.data.sanche.p_zongji);
                            $('.heji').val(res.data.sanche.heji);
                            // $(".hd_c_heji").val(res.data.sanche.hd_p_heji);
                            $(".hd_c_canzhi").val(res.data.sanche.hd_canzhi);
                            // $(".hd_c_zongji").val(res.data.sanche.hd_p_zongji);
                            $(".hd_d_shijiu").val(res.data.sanche.hd_g_shijiu);
                            $(".hd_d_zongji").val(res.data.sanche.hd_g_zongji)
                        },200)

                        // $(".hd_d_zongji").val("TEST123");
                        // console.log($(".hd_d_zongji").val()); // 是否变成 "TEST123"？

                        // $(".hd_d_zongji").attr("value",res.data.sanche.hd_g_zongji);
                        if (res.data.sangong.length > 0) {

                            for (var i = 0; i < res.data.sangong.length; i++) {
                                var price_he = '';
                                if (res.data.sangong1 == 1) {
                                    if (res.data.sangong[i].price_he > 0) {
                                        price_he = res.data.sangong[i].price_he;
                                    } else {
                                        price_he = res.data.sangong[i].price;
                                    }
                                } else {
                                    price_he = res.data.sangong[i].price_he;
                                }
                                var num_he = '';
                                if (res.data.sangong1 == 1) {
                                    if (res.data.sangong[i].num_he > 0) {
                                        num_he = res.data.sangong[i].num_he;
                                    } else {
                                        num_he = res.data.sangong[i].num;
                                    }
                                } else {
                                    num_he = res.data.sangong[i].num_he;
                                }
                                var hejia = '';
                                if (res.data.sangong1 == 1) {
                                    if (res.data.sangong[i].hejia > 0) {
                                        hejia = res.data.sangong[i].hejia;
                                    } else {
                                        hejia = res.data.sangong[i].money;
                                    }
                                } else {
                                    hejia = res.data.sangong[i].hejia;
                                }
                                html2 += "<tr>" +
                                    "<td><input class='hd_d_id' type='checkbox' style='width: 15px;height: 15px;display: block;' disabled name='id'  value=" + res.data.sangong[i].id + "></td>" +
                                    "<td><input type='text' name='xuhao' readonly value=" + res.data.sangong[i].xuhao + " ></td>" +
                                    // "<td><input type='text' name='type' readonly  value=" + res.data.sangong[i].type + "></td>" +
                                    "<td><input type='text' name='name' readonly  value=" + res.data.sangong[i].name + "></td>" +
                                    "<td><input type='text' name='fangan' readonly  value=" + res.data.sangong[i].fangan + "></td>" +
                                    "<td><input type='text' name='price' readonly value=" + res.data.sangong[i].price + "></td>" +
                                    "<td><input type='text' name='num' readonly value=" + res.data.sangong[i].num + " ></td>" +
                                    "<td><input type='text' name='money' readonly value=" + res.data.sangong[i].money + "></td>" +
                                    /*"<td><input type='text' name='zhekou' readonly value=" + res.data.sangong[i].zhekou + "></td>" +*/
                                    "<td><input oninput='hd_d()' class='hd_d_price' type='text' name='price_he'  value=" + price_he + "></td>" +
                                    "<td><input oninput='hd_d()' class='hd_d_num' type='text' name='num_he'  value=" + num_he + "></td>" +
                                    "<td><input class='hd_d_hejia' type='text' name='hejia'  value=" + hejia + "></td>" +
                                    "<td><input type='text' name='beizhu' readonly value=" + res.data.sangong[i].beizhu + "></td>" +
                                    "</tr>";
                            }
                        } else {
                            html2 += "<tr>" +
                                "<td><input type='checkbox' style='width: 15px;height: 15px;display: block;' disabled value='' name='id'></td>" +
                                "<td><input type='text' name='xuhao' value='1' readonly></td>" +
                                // "<td><input type='text' name='type' readonly ></td>" +
                                "<td><input type='text' name='name' readonly ></td>" +
                                "<td><input type='text' name='fangan' readonly ></td>" +
                                "<td><input type='text' name='price' readonly ></td>" +
                                "<td><input type='text' name='num' readonly ></td>" +
                                "<td><input type='text' name='money' readonly ></td>" +
                                /* "<td><input type='text' name='zhekou' readonly value='100'></td>" +*/
                                "<td><input type='text' name='price_he' readonly  ></td>" +
                                "<td><input type='text' name='num_he' readonly  ></td>" +
                                "<td><input type='text' name='hejia' readonly  ></td>" +
                                "<td><input type='text' name='beizhu' readonly ></td>" +
                                "</tr>";
                        }

                        $("#tabProduct8 tr").slice(1).remove();
                        $('#tabProduct8').append(html2);
                        setTimeout(function(){
                            $('.g_money').val(res.data.sanche.g_money);
                            // $('.g_hejia').val(res.data.sanche.g_hejia);
                            $('.hd_c_money').val(res.data.sanche.g_hejia);
                            $('.g_shijiu').val(res.data.sanche.g_shijiu);
                            $('.g_zongji').val(res.data.sanche.g_zongji);
                        },200)


                        if (res.data.sancai.length > 0) {
                            for (var i = 0; i < res.data.sancai.length; i++) {
                                html3 += "<tr>" +
                                    "<td><input type='checkbox' readonly style='width: 15px;height: 15px;display: block;' disabled name='id' value=" + res.data.sancai[i].id + "></td>" +
                                    "<td><input type='text' readonly name='xuhao' value=" + res.data.sancai[i].xuhao + "></td>" +
                                    "<td><input type='text' readonly name='type' value=" + res.data.sancai[i].type + "></td>" +
                                    "<td><input type='text' readonly name='name' value=" + res.data.sancai[i].name + "></td>" +
                                    "<td><input type='text' readonly name='fangan' value=" + res.data.sancai[i].fangan + " ></td>" +
                                    "<td><input type='text' readonly name='price' value=" + res.data.sancai[i].price + "></td>" +
                                    "<td><input type='text' readonly name='num'  value=" + res.data.sancai[i].num + "></td>" +
                                    "<td><input type='text' readonly name='money' value=" + res.data.sancai[i].money + " ></td>" +
                                    /* "<td><input type='text' readonly name='zhekou'  value=" + res.data.sancai[i].zhekou + " ></td>" +*/
                                    "<td><input type='text' readonly name='price_he'  value=" + res.data.sancai[i].price_he + "></td>" +
                                    "<td><input type='text' readonly name='num_he'  value=" + res.data.sancai[i].num_he + "></td>" +
                                    "<td><input type='text' readonly name='hejia'  value=" + res.data.sancai[i].hejia + "></td>" +
                                    "<td><input type='text' readonly name='beizhu' value=" + res.data.sancai[i].beizhu + "></td>" +
                                    "</tr>";
                            }
                        } else {
                            html3 += "<tr>" +
                                "<td><input type='checkbox' readonly style='width: 15px;height: 15px;display: block;' disabled name='id' value=''></td>" +
                                "<td><input type='text' name='xuhao' value='1' readonly ></td>" +
                                "<td><input type='text' readonly name='type'></td>" +
                                "<td><input type='text' name='name' readonly></td>" +
                                "<td><input type='text' name='fangan' readonly></td>" +
                                "<td><input type='text' name='price' readonly></td>" +
                                "<td><input type='text' name='num' readonly></td>" +
                                "<td><input type='text' name='money' readonly></td>" +
                                /*"<td><input type='text' name='zhekou' readonly value='100'></td>" +*/
                                "<td><input type='text' name='price_he' readonly></td>" +
                                "<td><input type='text' name='num_he' readonly></td>" +
                                "<td><input type='text' name='hejia' readonly></td>" +
                                "<td><input type='text' name='beizhu' readonly></td>" +
                                "</tr>";
                        }

                        $("#tabProduct4 tr").slice(1).remove();
                        $('#tabProduct4').append(html3);
                        setTimeout(function(){
                            $('.c_money').val(res.data.sanche.c_money);
                            $('.c_hejia').val(res.data.sanche.c_hejia);
                            $('.c_heji').val(res.data.sanche.c_heji);
                            $('.c_canzhi').val(res.data.sanche.c_canzhi);
                            $('.c_zongji').val(res.data.sanche.c_zongji);
                            $('.sanche_susong').val(res.data.sanche.sanche_susong);
                            $('.sanche_jianding').val(res.data.sanche.sanche_jianding);
                            $('.sanche_gonggu').val(res.data.sanche.sanche_gonggu);
                            $('.sanche_zhusu').val(res.data.sanche.sanche_zhusu);
                            $('.sanche_luqiao').val(res.data.sanche.sanche_luqiao);
                            $('.sanche_ranyou').val(res.data.sanche.sanche_ranyou);
                            $('.sanche_qita').val(res.data.sanche.sanche_qita);
                            $('.sanche_huizong').val(res.data.sanche.sanche_huizong);
                            $('.beizhu').val(res.data.sanche.beizhu);
                        },200)


                        hd_c();
                        hd_d();
                        d_c();
                        // 1. 克隆 #light 避免污染原始 DOM
                        console.log(11111)
                        // layer.title('详情', layerIndex); // 修改标题
                        // $('#layui-layer' + layerIndex).find('.layui-layer-content').html($('#light').html()); // 更新内容

                        layer.title('详情', layerIndex); // 修改标题
                        // $('#layui-layer' + layerIndex).find('.layui-layer-content').html($('#light2').html()); // 更新内容
                        $('#layui-layer' + layerIndex)
                            .find('.layui-layer-content')
                            .empty() // 先清空目标容器
                            .append($('#light').contents()); // 移动 #light2 的子节点（不复制）

                    }else{
                        layer.msg(res.msg || '数据加载失败', {icon: 2});
                    }
                }
            })
        }

        function closeDialog() {
            // var message = confirm('请确认是否已填完数据');
            // if (message) {
            document.getElementById('light').style.display = 'none';
            document.getElementById('fade').style.display = 'none'
            // }
        }
    </script>
</div>